package com.server;

import com.model.Student;
import com.model.User;

import java.util.List;

/**
 * 服务器端对数据的读取
 */
public class ServerDao {

    /**
     * 服务器检查客户端传来的管理员用户是否正确
     * @param user
     * @return
     */
    public boolean serverManagerCheck(User user){
        String right_userName = "admin";
        String right_passWord = "123456";
        if (right_userName.equals(user.getUserName()) && right_passWord.equals(user.getPassWord()))
            return true;
        return false;
    }

    /**
     * 服务器检查客户端传来的学员用户是否正确
     * @param user
     * @return
     */
    public boolean serverStudentCheck(User user){
        StudentSystemOperation studentSystemOperation = new StudentSystemOperation();
        studentSystemOperation.serverReadStudentFile();
        List<Student> students = studentSystemOperation.getStudents();
        for (Student student: students) {
            if (student.getUserName().equals(user.getUserName()) && student.getPassWord().equals(user.getPassWord()))
                return true;
        }
        return false;
    }
}
